<template>
	<scroll-view class="wrap" scroll-y="true">
		<view style="height: 20rpx;"></view>
		<view class="wrap-sh" v-for="(item,index) in rows" v-show="isLoadDowning == 0" :key="index"
			style="background: white;border-radius: 15rpx;width: 720rpx;margin: 0 auto 25rpx;">
			<view @click="deptName(item)">
				<view class="top">
					<view class="top-h">
						{{item.deptName}}
					</view>
				</view>
				<view class="information" style="border-bottom: 1rpx solid #dcdee4;">
					<text style="margin-right:5px;">{{item.rarea}}</text>{{item.street}}｜
					<text style="margin-right:5px;">{{item.metro}}</text>{{item.station}}站
				</view>
			</view>

			<view class="room" @click="roomName(item)">
				<view class="img">
					<image class="img" :src="item.showImgUrl" mode=""></image>
				</view>
				<view class="msg">
					<view class="p1">
						户型：{{item.modelName}}
					</view>
					<view class="p1">
						房号：{{item.roomNum}}
					</view>
					<view class="p1">
						面积：{{item.area}}m²
					</view>
					<!-- <view class="p1 p2">
							<text>bCur</text>
						</view> -->

					<view class="mon">
						租金：<text class="mon-y">{{item.monthPrice}}</text><text class="mon-s">元/月</text>
					</view>
				</view>
				<view class="btn">
					<view class="btn-gn wrap-sh" @tap.stop="makePhone(item.deptId)">
						电话咨询
					</view>
					<view class="btn-gn wrap-sh" @tap.stop="clickWx(item.deptId)">
						管家微信
					</view>
					<!-- <view class="btn-gn">
						预约看房
					</view> -->
				</view>
			</view>
		</view>
		<div class="load" v-show="isLoadDowning == 1">
			<img class="loadImg" src="https://gateway.yijushenyang.com/static/img/loading.png" alt="">
			<view style="height: auto;line-height: 0;color: #999;">加载中</view>
		</div>
		<div class="load" v-show="isLoadDowning == 2">
			<img src="https://gateway.yijushenyang.com/img/none.png"
				style="margin: 0 auto; margin-top: 40px; width: 50px; height:50px;" alt="">
			<view class="" style="margin-top: 10px; color: #999;line-height: 0;">
				暂无数据
			</view>
		</div>
		<view style="height: 80rpx;"></view>
	</scroll-view>
</template>

<script>
	export default {
		components: {

		},
		data() {
			return {
				openId: uni.getStorageSync('openId'),
				list: [],
				rows: [],
				phone: '',
				pageNum: 1,
				pageSize: 10,
				loadBottom: true,
				isLoadDowning: 1,
			}
		},
		onLoad(option) {},

		onShow() {
			this.getList()
		},

		onReachBottom() {
			if (this.loadBottom) {
				this.pageNum += 1;
				if (this.pageNum <= Math.ceil(this.list.total / this.pageSize)) {
					this.isLoadDowning = 1
					this.getList()
				}
			} else {
				this.isLoadDowning = 2
			}
		},

		onShareAppMessage(res) { //发送给朋友
			return {
				title: '逸居盛京',
				path: '/pages/home/index',
				imageUrl: "",
			}
		},
		onShareTimeline(res) { //分享到朋友圈
			return {
				title: '逸居盛京',
				path: '/pages/home/index',
				imageUrl: "",
			}
		},
		methods: {
			deptName(item) {
				console.log(item)
				uni.navigateTo({
					url: '/pages/builds/detail?id=' + item.deptId
				})
			},
			roomName(item) {
				uni.navigateTo({
					url: '/pages/builds/room?modelId=' + item.modelId + '&deptId=' + item.deptId
				})
			},
			clickWx(e) {
				uni.navigateTo({
					url: '/pages/wxuqrCode/index?deptId=' + e
				})
			},
			makePhone(num) {
				let pream = {
					deptId: num,

				}

				this.api.get('fangyuan/store/app/storeAppPeriphery', pream).then(res => {
					if (res.data.code == 200) {
						uni.makePhoneCall({
							phoneNumber: res.data.data.housekeepPhone,
							success: function() {
								// console.log("拨打电话成功！")
							},
							fail: function() {
								// console.log("拨打电话失败！")
							}
						});

					}
				})
			},

			getList() {
				this.isLoadDowning = 1
				let old = this.rows
				let data = {
					openId: uni.getStorageSync('openId'),
					pageNum: this.pageNum,
					pageSize: this.pageSize,
				}

				if (uni.getStorageSync('openId')) {
					this.api.get('system/collect/app/selByOpenIdPage', data).then(res => {
						if (res.data.code == 200) {
							if (res.data.total > 0) {
								this.isLoadDowning = 0
								this.list = res.data
								this.rows = res.data.rows

								let news = res.data.rows
								if (this.pageNum > 1) {
									this.isLoadDowning = 0
									this.rows = old.concat(news)
								}
							} else {
								this.isLoadDowning = 2
							}

						} else if (res.data.code == 500) {
							this.loginTip()
						}
					})
				} else {
					this.loginTip()
				}
			},

			loginTip() {
				uni.showToast({
					title: '请登陆',
					icon: 'none',
					duration: 2000
				});
				setTimeout(() => {
					uni.reLaunch({
						url: '/pages/login/login'
					})
				}, 2000);
			},
		}
	}
</script>

<style>
	@import '/common/css/my/collect.scss';
</style>

<style lang="scss">
	.wrap {
		@include wrap
	}


	.load {
		width: 100%;
		height: 20vh;
		line-height: 20vh;
		text-align: center;
		color: black;
		font-size: 32rpx;
		margin: 0 auto;
	}

	.loadImg {
		width: 250rpx;
		height: 250rpx;
		margin-top: 100rpx
	}

	.top {
		width: 680rpx;
		padding: 25rpx 35rpx 10rpx;
		font-size: $h;
		font-weight: bold;
		@include omit;
	}
</style>